package com.neusoft.elm.View.impl;

import java.util.List;
import java.util.Scanner;

import com.neusoft.elm.View.BusinessView;
import com.neusoft.elm.dao.BusinessDao;
import com.neusoft.elm.dao.impl.BusinessDaoImpl;
import com.neusoft.elm.po.Business;

public class BusinessViewImpl implements BusinessView {
    private Scanner input = new Scanner(System.in);
	@Override
	public void ListBusinessAll() {
		BusinessDao dao = new BusinessDaoImpl();
		List<Business> List=dao.listBusiness(null,null);
		System.out.println("商家编号\t商家名称\t商家地址\t商家介绍\t起送费\t配送费");
		for(Business b:List){
			System.out.println(b.getBusinessId()+"\t"
					+b.getBusinessName()+"\t"
					+b.getBusinessAddress()+"\t"
					+b.getBusinessExplain()+"\t"
					+b.getStarPrice()+"\t"
					+b.getDeliveryPrice()
					);
			
		}
		
	}

	@Override
	public void ListBusiness() {
		// TODO Auto-generated method stub
		String businessName="";
		String businessAddress="";
		String inputStr="";
		System.out.println("是否需要商家名称关键词(y/n):");
		inputStr=input.next();
		if(inputStr.equals("y")){//字符串是否相等是.equals
			System.out.println("请输入商家名字关键字:");
			businessName=input.next();
		}
		System.out.println("是否需要商家地址关键词(y/n):");
		inputStr=input.next();
		if(inputStr.equals("y")){//字符串是否相等是.equals
			System.out.println("请输入商家地址关键字:");
			businessAddress=input.next();
			
			
		}

		BusinessDao dao = new BusinessDaoImpl();
		List<Business> List=dao.listBusiness(businessName,businessAddress);
		System.out.println("商家编号\t商家名称\t商家地址\t商家介绍\t起送费\t配送费");
		for(Business b:List){
			System.out.println(b.getBusinessId()+"\t"
					+b.getBusinessName()+"\t"
					+b.getBusinessAddress()+"\t"
					+b.getBusinessExplain()+"\t"
					+b.getStarPrice()+"\t"
					+b.getDeliveryPrice()
					);
			
		}
		
	}

}
